import VueRouter from 'vue-router'
import Login from '@/views/Login.vue'
import Layout from '@/views/Layout.vue'
import Register from '@/views/Register.vue'
import Detail from '@/views/Detail.vue'
import Vue from 'vue'
// 子组件
import Article from '@/views/Article.vue'
import Collect from '@/views/Collect.vue'
import Like from '@/views/Like.vue'
import User from '@/views/User.vue'
import Updata from '@/views/updata.vue'
import Recommend from '@/views/recommend.vue'
Vue.use(VueRouter)
const router = new VueRouter({
    mode:'history',
  linkActiveClass: 'active',
  linkExactActiveClass: 'ex-active',
  routes: [
    //外层切换 父路由
    { path: '/', redirect: '/layout' },
    {
        path: '/detail/:id',
          component: Detail,
   
      },
    {
        path: '/register',
          component: Register,
      },
    {
      path: '/login',
        component: Login,
    },
    //将来用于放置 子路由+4个导航
    {
      path: '/layout',
        component: Layout,
        // 子路由路径 必须以父路径开头

        children: [
            //写一个重定向
            { path: '/layout/', redirect: '/layout/article' },
          {
            path: '/layout/article',
            // 子路由组件
            component: Article,
            children:[
                {
                    path: '/layout/article/recommend',
                    component:Recommend,
                  },
                  {
                    path: '/layout/article/updata',
                    component:Updata,
                  },
            ]
          },
          {
            path: '/layout/collect',
            component:Collect,
          },
          {
            path: '/layout/like',
            component:Like,
          },
          {
           path: '/layout/user',
           component:User,
          }
        ]
    }
    
  ]
})
export default router